package com.demo2do.boyle.common.entity.system;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 
 * @author Jason.Y
 */
@Entity
@Table(name = "role_menu")
public class RoleMenu {
    
    @Id
    @GeneratedValue
    private Integer id;
    
    @Column(name = "role_name",nullable = false)
    private String roleName;
    
    @Column(name = "menus")
    private String menus;
    
    @Column(name = "submenus")
    private String submenus;
    
    
    @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @Fetch(FetchMode.SELECT)
    @PrimaryKeyJoinColumn
    @JSONField(serialize = false)
    private Role role;
    
    /**
     * The default constructor
     */
    public RoleMenu() {
        
    }

	public Integer getId() {
		return id;
	}

	public String getRoleName() {
		return roleName;
	}

	public String getMenus() {
		return menus;
	}

	public String getSubmenus() {
		return submenus;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public void setMenus(String menus) {
		this.menus = menus;
	}

	public void setSubmenus(String submenus) {
		this.submenus = submenus;
	}

	/**
     * Initialize RoleMenu basic fields
     * @param roleName
     * @param menus
     * @param submenus
     * @return
     */
    public RoleMenu initialize(Role role) {

        this.role = role;
        
        return this;
    }
}
